<?php

namespace Admin\Assist\Controllers;

/**
 * Created by PhpStorm.
 * User: Lvyj
 * Date: 2017/6/21 0021
 * Time: 9:53
 */
use Helpers\Assets;
use Helpers\Main;
use Helpers\Template;

class InstructionsController extends ControllerBase
{

    public function indexAction()
    {
        $this->view->pick("instruction/index");
        Assets::easyUI('js/instruction.js');
        Template::exists('instruction', 'list') or die(Main::showMessageModal('配置文件不存在，请先创建！', 109106002));
        $listButtonArr = $formButtonArr = $listSearchArr = array();

        $listButtonArr[] = array('plain' => 'true', 'id' => 'bt_list_add', 'text' => '增加', 'icon' => 'fa-plus');
        $listButtonArr[] = array('plain' => 'true', 'id' => 'bt_list_del', 'text' => '删除', 'icon' => 'fa-trash');

        $formButtonArr[] = array('id' => 'bt_form_add', 'text' => '增加', 'class' => 'disabled');
        $formButtonArr[] = array('id' => 'bt_form_edit', 'text' => '修改', 'class' => 'disabled');
        //$formButtonArr[] = array('id' => 'bt_form_back', 'text' => '返回');
        $formButtonArr[] = array('id' => 'bt_form_reset', 'text' => '重置');

        $listSearchArr[] = array('placeholder' => '搜索一下', 'type' => 'text', 'id' => 'List_Search', 'label' => ' 搜索： ');
        $this->view->setVars(array(
            'instructionList' => Template::createList('instruction_List', 'instruction', [
                'searchToolbar' => Template::createSearchToolBar($listSearchArr, true),
                'buttonToolbar' => Template::createButtonToolBar($listButtonArr)
            ]),
            'Form' => Template::createForm('instruction'),
            'FormButton' => Template::createButtonToolBar($formButtonArr)
        ));
    }

}